package com.hnjd.util;

public class PageUtil {
 
	private Integer count;
	
	private Integer pageSize;
	
	private Integer curPage;
	
	private Integer pages;
	
	private Integer start;

	
	
	
	public PageUtil(Integer count, Integer pageSize, Integer curPage) {
		super();
		this.count = count;
		this.pageSize = pageSize;
		this.curPage = curPage;
		this.setPages();
		if(this.curPage>this.pages) {
			this.curPage=this.pages;
		}
		if(this.curPage<1) {
			this.curPage=1;
		}
		this.setStart();
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getCurPage() {
		return curPage;
	}

	public void setCurPage(Integer curPage) {
		this.curPage = curPage;
	}

	public Integer getPages() {
		return pages;
	}

	public void setPages() {
		if(count%pageSize==0) {
			this.pages = count/pageSize;
		}else {
			this.pages = count/pageSize+1;
		}
	}

	public Integer getStart() {
		return start;
	}

	public void setStart() {
		this.start =(curPage-1)*pageSize ;
	}

	@Override
	public String toString() {
		return "PageUtil [count=" + count + ", pageSize=" + pageSize + ", curPage=" + curPage + ", pages=" + pages
				+ ", start=" + start + "]";
	}
	
	
	
}
